@echo on

if NOT "%1"=="" (
	if NOT "%2"=="" GOTO :ARGSOK
)

:ERROR
echo "usage: CompleteBuild <clean|build> <Release|Debug> [<BUILD|SDK>]
GOTO :EOF

:ARGSOK

cls

set FLAVOR=%2
set TARGET=%1
set VERBOSITY=m
rem set LOGGING=/clp:ShowCommandLine /fileLogger
rem set LOGGING=/clp:ErrorsOnly /clp:WarningsOnly
rem set MMP_PE_Verbose=True
rem set MMP_STUB_Verbose=True
rem set MMP_DUMP_Verbose=True
rem set MMP_DAT_Verbose=True
rem set MMP_XML_Verbose=True

rem delete object file to regenerate build date
del %SPOCLIENT%\BuildOutput\ARM\RVDS4.0\le\RAM\debug\HAG\obj\DeviceCode\Initialization\tinyhal.obj
del %SPOCLIENT%\BuildOutput\ARM\RVDS4.0\le\RAM\debug\HAG\obj\DeviceCode\Initialization\reducesize\tinyhal.obj

if "%3"=="SDK" (
cd %SPOCLIENT%
Msbuild sdk.dirproj %LOGGING% /T:build /p:flavor=%FLAVOR%
)

if "%3"=="BUILD" (
cd %SPOCLIENT%
Msbuild build.dirproj %LOGGING% /T:build /p:flavor=%FLAVOR%
)

:buildsolution

cd %SPOCLIENT%\solutions\HAG\ManagedCode
msbuild build.dirproj %LOGGING% /t:%TARGET% /p:memory=RAM;flavor=debug;HAG_CFG=HAG32 /v:%VERBOSITY%
msbuild build.dirproj %LOGGING% /t:%TARGET% /p:memory=RAM;flavor=debug;HAG_CFG=HAG32 /v:%VERBOSITY%

cd %SPOCLIENT%\solutions\HAG
msbuild dotnetmf.proj %LOGGING% /t:%TARGET% /p:memory=RAM;flavor=%FLAVOR%;HAG_CFG=HAG32 /v:%VERBOSITY%

:EOF
cd %SPOCLIENT%\Solutions\HAG
echo done.